import {RouterMount,createRouter} from 'uni-simple-router';
import modules from './modules';

const router = createRouter({
	platform: process.env.VUE_APP_PLATFORM,  

	routerErrorEach:({type,level,...args})=>{
		// #ifdef APP-PLUS
			if(type===3){
				router.$lockStatus=false;
				uni.showModal({
                    title: '提示',
                    content: '您确定要退出应用吗？',
                    success: function (res) {
                        if (res.confirm) {
                            plus.runtime.quit();
                        } 
                    }
                });
			}
		// #endif
	},
	routes: [...modules]
});
//全局路由前置守卫
router.beforeEach((to, from, next) => {
	
	// console.log(to.name,from.name,'全局路由前置守卫')
	next();
});
// 全局路由后置守卫
router.afterEach((to, from) => {
    // console.log(to,from,'跳转结束')
})

export {
	router,
	RouterMount
}